//
//  SmallDecisionsZxhOrDmxComplateViewController.m
//  SmallDecisions
//
//  Created by 李付雄 on 2025/7/25.
//

#import "SmallDecisionsZxhOrDmxComplateViewController.h"
#import "SmallDecisionsZxhData.h"
#import "SmallDecisionsDmxData.h"

@interface SmallDecisionsZxhOrDmxComplateViewController ()

@property(nonatomic,strong)UIView *zxhOrDmxContainerView;
@property(nonatomic,strong)UILabel *zxhOrDmxTitleLabel;
@property(nonatomic,strong)UILabel *zxhOrDmxContentLabel;
@property(nonatomic,strong)UIButton *zxhOrDmxSureBtn;

@end

@implementation SmallDecisionsZxhOrDmxComplateViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self zxhOrDmxContainerView];
    [self zxhOrDmxTitleLabel];
    [self zxhOrDmxContentLabel];
    [self zxhOrDmxSureBtn];
    self.zxhOrDmxTitleLabel.text = self.title;
    if([self.title isEqualToString:@"大冒险"]) {
        NSArray *data = [SmallDecisionsDmxData getSmallDecisionsDmxModelDataWithType:self.userSelectModelType];
        NSInteger index = arc4random() % data.count;
        self.zxhOrDmxContentLabel.text = data[index];
    } else {
        NSArray *data = [SmallDecisionsZxhData getSmallDecisionsZxhModelDataWithType:self.userSelectModelType];
        NSInteger index = arc4random() % data.count;
        self.zxhOrDmxContentLabel.text = data[index];
    }
}


- (UIView *)zxhOrDmxContainerView {
    if(!_zxhOrDmxContainerView) {
        _zxhOrDmxContainerView = [[UIView alloc] init];
        _zxhOrDmxContainerView.backgroundColor = SmallDecisionsPurpleColor;
        _zxhOrDmxContainerView.layer.cornerRadius = 10;
        _zxhOrDmxContainerView.layer.masksToBounds = YES;
        [self.view addSubview:_zxhOrDmxContainerView];
        [_zxhOrDmxContainerView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(30);
            make.right.mas_equalTo(-30);
            make.centerY.mas_equalTo(0);
        }];
    }
    return _zxhOrDmxContainerView;
}

- (UILabel *)zxhOrDmxTitleLabel {
    if(!_zxhOrDmxTitleLabel) {
        _zxhOrDmxTitleLabel = [[UILabel alloc] init];
        _zxhOrDmxTitleLabel.textColor = SmallDecisionsYellowColor;
        _zxhOrDmxTitleLabel.text = self.title;
        _zxhOrDmxTitleLabel.font = SmallDecisionsSetFontSize(18);
        _zxhOrDmxTitleLabel.textAlignment = 1;
        _zxhOrDmxTitleLabel.numberOfLines = 0;
        [self.zxhOrDmxContainerView addSubview:_zxhOrDmxTitleLabel];
        [_zxhOrDmxTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(30);
            make.left.mas_equalTo(20);
            make.right.mas_equalTo(-20);
        }];
    }
    return _zxhOrDmxTitleLabel;
}

- (UILabel *)zxhOrDmxContentLabel {
    if(!_zxhOrDmxContentLabel) {
        _zxhOrDmxContentLabel = [[UILabel alloc] init];
        _zxhOrDmxContentLabel.textColor = SmallDecisionsThemeFontColor;
        _zxhOrDmxContentLabel.font = SmallDecisionsSetBoldFontSize(28);
        _zxhOrDmxContentLabel.numberOfLines = 0;
        _zxhOrDmxContentLabel.textAlignment = 1;
        [self.zxhOrDmxContainerView addSubview:_zxhOrDmxContentLabel];
        [_zxhOrDmxContentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.zxhOrDmxTitleLabel.mas_bottom).mas_offset(30);
            make.left.right.mas_equalTo(self.zxhOrDmxTitleLabel);
            make.bottom.mas_equalTo(-30);
        }];
    }
    return _zxhOrDmxContentLabel;
}

- (UIButton *)zxhOrDmxSureBtn {
    if(!_zxhOrDmxSureBtn) {
        _zxhOrDmxSureBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_zxhOrDmxSureBtn setTitle:@"确定" forState:UIControlStateNormal];
        [_zxhOrDmxSureBtn setTitleColor:SmallDecisionsThemeFontColor forState:UIControlStateNormal];
        [_zxhOrDmxSureBtn setTitleColor:[UIColor clearColor] forState:UIControlStateHighlighted];
        _zxhOrDmxSureBtn.titleLabel.font = SmallDecisionsSetBoldFontSize(16);
        _zxhOrDmxSureBtn.layer.cornerRadius = 30;
        _zxhOrDmxSureBtn.layer.masksToBounds = YES;
        _zxhOrDmxSureBtn.backgroundColor = SmallDecisionsThemeColor;
        [_zxhOrDmxSureBtn addTarget:self action:@selector(zxhOrDmxSureBtnBtnAction) forControlEvents:UIControlEventTouchUpInside];
        [self.view addSubview:_zxhOrDmxSureBtn];
        [_zxhOrDmxSureBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.height.mas_equalTo(60);
            make.left.equalTo(self.zxhOrDmxContainerView).offset(20);
            make.right.equalTo(self.zxhOrDmxContainerView).offset(-20);
            make.top.equalTo(self.zxhOrDmxContainerView.mas_bottom).offset(40);
        }];
    }
    return _zxhOrDmxSureBtn;
}

- (void)zxhOrDmxSureBtnBtnAction {
    [SmallDecisionsNavigatorManager dismissViewControllerAnimated:YES completion:nil];
}

@end
